package common.utils.properties;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class SharedPreferencesUtils {
	
	private static SharedPreferences preferences = null;
	
	private static void init(Context context){
		if(preferences == null){
			preferences = PreferenceManager.getDefaultSharedPreferences(context);
		}
	}
	
	public static String getSharedPref(Context context, String key){
		init(context);
		return preferences.getString(key, "zekezang");
	}
	
	public static void setSharedPref(Context context, String key, String value){
		init(context);
		SharedPreferences.Editor editor = preferences.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public static boolean compare(Context context, String key, String value){
		init(context);
		String val = getSharedPref(context, key);
		return val.equals(value)?true:false;
	}
	
	public static void removeSharedPref(Context context, String key){
		init(context);
		SharedPreferences.Editor editor = preferences.edit();
		editor.remove(key);
		editor.commit();
	}

}
